package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-07-09 15:26
 */
public class Solution_0258 {
    /**
     * 各位相加
     *
     * @param num
     * @return
     */
    public int addDigits(int num) {
        if (num < 10) {
            return num;
        }
        int next = 0;
        while (num != 0) {
            next = next + num % 10;
            num /= 10;
        }
        return addDigits(next);
    }
}
